// pages/team/index.js
import {
  request
} from "../../request/request.js";

Page({

  /**
   * 页面的初始数据
   */
  data: {
    admin:[],
    member:[
      {
        id:0,
        group_name:"足球队"
      }
    ],
    group:[]
  },
  onLoad: function (options) {
    var that = this;
        let baseUrl = 'http://172.17.60.141/';
        let StudentID = wx.getStorageSync("StudentID");
        request({
                url: baseUrl + 'group/Member',
                data: {
                  StudentID: StudentID,
                },
                method: 'GET',
            })
            .then(result => {
              console.log(result.data);
              //我管理的模块
                for(let i=0;i<result.data.length;i++){
                  console.log(result.data[i].GroupID);
                    if(result.data[i].Auth==1){
                      var newArray = result.data[i].GroupID
                      that.data.admin = that.data.admin.concat(newArray);
                      that.setData({
                        admin: that.data.admin,
                        group:result.data})
                        wx.setStorageSync('group', that.data.group)
                  }
                }
              //我加入的模块
              // for(let i=0;i<result.data.group_join.length;i++){
              //   var newArray = result.data.group_join[i]
              //   that.data.member = that.data.member.concat(newArray);
              //   // console.log(that.data.member);
              //   that.setData({
              //     member: that.data.member,
              //   })
              // }
            })
},
  toAddteam:function(e){
    wx.navigateTo({
      url: '/pages/addteam/index',
    })
  },
  toJointeam:function(e){
    wx.navigateTo({
      url: '/pages/JoinTeam/index',
    })
  },
  //获取点击信息
  // getInfo:function (e) {
  //     console.log(e.target.dataset)
  // }

})
